# coding=utf-8

import memcache  
#创建连接  
mc_client = memcache.Client(['127.0.0.1:11211'], debug=0)  
#写、读  
mc_client.set("key_a", "value_a")  
value = mc_client.get("key_a")  
print "key_a 's value in memcached is: %s" %(value)  
#删  
mc_client.delete("key_a")  
value = mc_client.get("key_a")  
print "key_a 's value in memcached after deleted is: %s" %(value)  
#自增、自减  
mc_client.set("count_key", "11")  
value = mc_client.get("count_key")  
print "general value: ", value  
mc_client.incr("count_key")  
value = mc_client.get("count_key")  
print "general value after increment: ", value  
mc_client.decr("count_key")  
value = mc_client.get("count_key")  
print "general value after decrement: ", value  